//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Serialization;

namespace OpenLS.Drawing
{
    internal sealed class DrawingInstanceProvider : IOfficeInstanceProvider
    {
        #region IOfficeInstanceProvider Members

        /// <summary>
        /// Returns an instance from a context, null if unknown
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public IOfficeXmlSerializable ReadInstance(ReadContext context)
        {
            if (context.Reader.NamespaceURI == DrawingConstants.DrawingNamespaceUri)
            {
                if (context.ReaderLocalName == "tbl")
                {
                    return context.ReadElement<Table>();
                }
            }
            if (context.Reader.NamespaceURI == DrawingConstants.CompatibilityNamespaceUri)
                    if (context.ReaderLocalName == "legacyDrawing")
                    {
                        return context.ReadElement<LegacyDrawing>();
                    }
            
            return null;
        }

        #endregion
    }
}